package com.wecan.base.utils;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.wecan.base.BO.SystemMessageContentBO;
import com.wecan.base.enums.*;

/**
 * @Author liuzhihao
 * @Date 2022.04.07
 * @Version ${version}
 * @Description ${description}
 */
public class TemplateUtils {

    /**
     * 文章审核模板
     *
     * @param id
     * @param status
     * @param reason
     * @return
     */
    public static SystemMessageContentBO getKnowledgeApproval(Long id, String knowledgeTitle, ApprovalStatus status, String reason) {
        SystemMessageContentBO systemMessageContentBO = new SystemMessageContentBO();
        systemMessageContentBO.setId(id);
        systemMessageContentBO.setTitle("文章审核通知");
        systemMessageContentBO.setMessage("标题：" + knowledgeTitle + "\n" + "状态：" + status.getDesc() + "\n" + "原因：" + (StringUtils.isEmpty(reason) ? "无" : reason));
        return systemMessageContentBO;
    }

    /**
     * 文章下线
     *
     * @param id
     * @param knowledgeTitle
     * @return
     */
    public static SystemMessageContentBO knowledgeOffline(Long id, String knowledgeTitle) {
        SystemMessageContentBO systemMessageContentBO = new SystemMessageContentBO();
        systemMessageContentBO.setId(id);
        systemMessageContentBO.setTitle("文章下线通知");
        systemMessageContentBO.setMessage("标题：" + knowledgeTitle + "\n" + "您的文章由于违反平台内容规范，暂时下线，具体可联系平台客服");
        return systemMessageContentBO;
    }

    /**
     * 构建反馈系统消息
     *
     * @param status
     * @return
     */
    public static SystemMessageContentBO feedbackDeal(IsNotIsStatus status) {
        SystemMessageContentBO systemMessageContentBO = new SystemMessageContentBO();
        systemMessageContentBO.setTitle("反馈通知");
        systemMessageContentBO.setMessage(status == IsNotIsStatus.IS ? "您提交的反馈已处理，感谢您的提交。" : "反馈无法处理，感谢你的提交。");
        return systemMessageContentBO;
    }

    /**
     * 构建订单退款通知
     *
     * @return
     */
    public static SystemMessageContentBO refundSuccess(Long id, double money) {
        SystemMessageContentBO systemMessageContentBO = new SystemMessageContentBO();
        systemMessageContentBO.setId(id);
        systemMessageContentBO.setTitle("退款通知");
        systemMessageContentBO.setMessage("您的订单已经退款，退款金额为" + money + "元，有其他疑问请联系客服。");
        return systemMessageContentBO;
    }

    /**
     * 构建订单退款审批通知
     *
     * @param id
     * @param status
     * @param reason
     * @return
     */
    public static SystemMessageContentBO buildApprovalRefund(Long id, OrderRefundStatus status, String reason) {
        SystemMessageContentBO systemMessageContentBO = new SystemMessageContentBO();
        systemMessageContentBO.setId(id);
        systemMessageContentBO.setTitle("退款申请通知");
        StringBuffer stringBuffer = new StringBuffer();
        if (status == OrderRefundStatus.WAIT_PLATFORM_CONFIRM) {
            stringBuffer.append("用户未通过您的退款申请，待平台进一步确认。\n");
        } else if (status == OrderRefundStatus.PASSIVE_PLATFORM_NO_PASS) {
            stringBuffer.append("平台未通过您的退款申请，有其他疑问可以继续联系客服。\n");
        } else if (status == OrderRefundStatus.PASS) {
            stringBuffer.append("您的退款申请已通过，由于收费内容已经被观看，所以退款金额只能达到总金额的一半，有其他疑问可以继续联系客服。\n");
        }
        stringBuffer.append("原因：");
        if (StringUtils.isNotEmpty(reason)) {
            stringBuffer.append("无");
        } else {
            stringBuffer.append(reason);
        }
        systemMessageContentBO.setMessage(stringBuffer.toString());
        return systemMessageContentBO;
    }

    /**
     * 构建平台申请通过通知
     *
     * @param id
     * @return
     */
    public static SystemMessageContentBO buildResultRefund(Long id, String reason) {
        SystemMessageContentBO systemMessageContentBO = new SystemMessageContentBO();
        systemMessageContentBO.setId(id);
        systemMessageContentBO.setTitle("退款结果通知");
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append("您的一个订单已经被平台确认需要退款，退款所需要的费用由平台支出。\n多发优质内容，共建青春家园。\n原因：");
        stringBuffer.append(reason);
        systemMessageContentBO.setMessage(stringBuffer.toString());
        return systemMessageContentBO;
    }

    /**
     * 构建退款申请处理单
     *
     * @param id
     * @return
     */
    public static SystemMessageContentBO buildWaitDealRefund(Long id) {
        SystemMessageContentBO systemMessageContentBO = new SystemMessageContentBO();
        systemMessageContentBO.setId(id);
        systemMessageContentBO.setTitle("退款申请待处理");
        systemMessageContentBO.setMessage("您有一个退款申请待处理，请及时处理。");
        return systemMessageContentBO;
    }
}
